home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
wb
/
czesc_2
/
iconextras
/
src
/
copyicon
/
copyicon.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-01-13
|
1KB
|
59 lines
#include <exec/types.h>
#include <workbench/workbench.h>
#include <workbench/startup.h>
#include <libraries/dos.h>
#include <clib/alib_protos.h>
#include <clib/icon_protos.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void cleanexit(int error);
struct Library *IconBase = NULL;
struct DiskObject *dobj = NULL;
void main(int argc,char *argv[]) {
if(argc!=3) {
printf("Usage:\n");
printf("%s <source icon [.info]> <destination icon [.info]>\n",argv[0]);
cleanexit(RETURN_OK);
}
if(!(IconBase=OpenLibrary("icon.library",33))) {
printf("Couldn't open icon.library\n");
cleanexit(RETURN_FAIL);
}
/* Strip .info from end of each filename if it ends that way */
if(strlen(argv[1]) > 5 && !strcmp(&argv[1][strlen(argv[1])-5],".info"))
argv[1][strlen(argv[1])-5]='\0';
if(strlen(argv[2]) > 5 && !strcmp(&argv[2][strlen(argv[2])-5],".info"))
argv[2][strlen(argv[2])-5]='\0';
if(!(dobj=GetDiskObject(argv[1]))) {
printf("File not found\n");
cleanexit(RETURN_FAIL);
}
dobj->do_CurrentX=dobj->do_CurrentY=NO_ICON_POSITION;
if(!PutDiskObject(argv[2],dobj)) {
printf("Couldn't open output file\n");
cleanexit(RETURN_FAIL);
}
cleanexit(RETURN_OK);
}
void cleanexit(int error) {
if(IconBase) CloseLibrary(IconBase);
if(dobj) FreeDiskObject(dobj);
exit(error);
}